package org.sn.jdish.spring.springboot.controller;

import org.sn.jdish.spring.springboot.base.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * springboot helloworld
 * 
 * @author snzigod@hotmail.com
 */
@Controller
@RequestMapping("/demo")
public class DemoController {

	@ResponseBody
	@RequestMapping("/helloworld")
	String home() throws Exception {
		throw new Exception("erro!");
	}

	@RequestMapping("/erro")
	public String erro() {
		throw new MyException("发生错误2");
	}
	
	@RequestMapping("/")
    public String index(ModelMap map) {
        map.addAttribute("host", "http://www.cnblogs.com/snzigod");
        return "index";
    }

}